import 'package:base/widget/bubble/bubble_painter.dart';
import 'package:base/widget/bubble/bubble_tip_widget.dart';
import 'package:flutter/material.dart';

class BubbleDialog extends StatelessWidget {
  final String text;
  final ArrowLocation arrowLocation;

  ///控件宽度
  final double width;

  ///控件高度
  final double height;

  ///控件圆角
  final double radius;

  ///需要三角形指向的x坐标
  final double x;

  ///需要三角形指向的y坐标
  final double y;
  final VoidCallback voidCallback;

  BubbleDialog(
    this.text, {
    this.width,
    this.height,
    this.radius = 4,
    this.arrowLocation = ArrowLocation.BOTTOM,
    this.voidCallback,
    this.x = 0,
    this.y = 0,
  });

  void confirm(context) {
    Navigator.of(context).pop();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: InkWell(
        splashColor: Colors.transparent,
        highlightColor: Colors.transparent,
        onTap: () {
          confirm(context);
        },
        child: Container(
          alignment: Alignment.centerLeft,
          child: BubbleTipWidget(
              arrowLocation: arrowLocation,
              width: width,
              height: height,
              radius: radius,
              x: x,
              y: y,
              text: text,
              voidCallback: () {
                confirm(context);
              }),
        ),
      ),
    );
  }
}
